package com.jiepos.mpos.biz.appInfM.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.jiepos.mpos.biz.appInfM.service.LogErrorReportService;
import com.jiepos.mpos.common.entity.App_Log_ErrorReportEntity;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;



/**
 *
 *
 * <p>标题: —— 控制器</p>
 * <p>模块: 通用平台</p>
 * <p>版权: Copyright (c) 2017 江苏杰博实信息技术有限公司
 * @ProjectName:  [mpos]
 * @Package com.jiepos.mpos.biz.
 * @author 余翼膑
 * @version 1.0
 * @since 2018年2月07号
 * @history（历次修订内容、修订人、修订时间等）
 */

@Controller
@RequestMapping("errorReport")
public class LogErrorReportController extends BaseController {


    @Autowired
    private LogErrorReportService logErrorReportService;

    /**
     * 进入列表页面
     * @param request
     * @param response
     * @param pagination
     * @return
     */
    @RequestMapping("/getErrorReportList.do")
    public ModelAndView getErrorReportList(HttpServletRequest request, HttpServletResponse response, Pagination pagination){

        ModelAndView model = new ModelAndView("/module/appInfM/errorReport/errorReport_list");
        return super.getDetail(request, response, model);
    }

    /**
     * 查询列表信息json数据
     * @param pagination
     * @param appLogErrorReportEntity
     * @return
     */
    @RequestMapping("/errorReportListJson.do")
    public @ResponseBody
    Map getErrorReportListJson(HttpServletRequest request, Pagination pagination, App_Log_ErrorReportEntity appLogErrorReportEntity,String start_date,String end_date){
        return logErrorReportService.getErrorReportList(request,pagination, appLogErrorReportEntity,start_date,end_date);
    }

    /**
     * 进入详细页面
     * @param request
     * @param response
     * @param pagination
     * @param report_uuid
     * @return
     */
    @RequestMapping("/getErrorReportDetail.do")
    public ModelAndView getErrorReportDetail(HttpServletRequest request, HttpServletResponse response,
                                              Pagination pagination,String report_uuid) {
        ModelAndView model = new ModelAndView("/module/appInfM/errorReport/errorReport_detail");
        // 菜单编码
        Map errorReportEntity = logErrorReportService.getErrorReportById(report_uuid);
        model.addObject("errorReportEntity", errorReportEntity);
        return super.getDetail(request, response, model);
    }
    /**
     * 下载文件
     * @param request
     * @param response
     * @param fileName
     */
    @RequestMapping("/exportFile.do")
    @ResponseBody
    public void exportTransactionLogs(HttpServletRequest request, HttpServletResponse response,
                                      String fileName) {
        super.clearCookie(request, response);
        logErrorReportService.downloadFile(fileName, response, request);
    }


}
